#include "BusinessLogic.hpp"
#include "DRCDB.hpp"
#include "User.hpp"
#include "Data.hpp"

#include <string>
#include <typeinfo>
using namespace std;

BusinessLogic* BusinessLogic::businessLogic = NULL;

BusinessLogic::BusinessLogic()
{}

BusinessLogic* BusinessLogic::singleton()
{
	if (businessLogic == NULL)
		businessLogic = new BusinessLogic();
	return businessLogic;
}

void BusinessLogic::createDatabase(string db_string)
{
	db = new DRCDB(db_string);
}

BusinessLogic::~BusinessLogic()
{
	delete db;
}

enum LoginStatus BusinessLogic::login(User* user)
{
	LoginStatus loginStatus = db->login(user);
	return loginStatus;

	// different stuff will probably happen in each of the different events
	// for instance, when a successful login occurs, the user object should be stored as the active user
	/*
	switch (loginStatus)
	{
		case LoginSuccess:
			cout << "Login Successful" << endl;
			this->user = user;
			break;
		case LoginInvalidUser:
			cout << "Login Failed: Invalid User" << endl;
			//delete user;
			break;
		case LoginInvalidPassword:
			cout << "Login Failed: Invalid Password" << endl;
			//delete user;
			break;
		default:
			break;
	}
	return loginStatus;
	*/
	//db.login(user);
}
